package com.bookmanger.controller;

import com.bookmanger.common.result.Result;
import com.bookmanger.entity.dto.UserInfoDTO;
import com.bookmanger.entity.request.UserInfoRequest;
import com.bookmanger.service.UserService;
import org.springframework.web.bind.annotation.*;

/**
 * @folder 个人中心
 * @author wei kunJie
 * @date 2024/11/5 15:05:05
 */
@RestController
@RequestMapping("/api/userCenter")
public class UserCenterController {

    private UserService userService;

    public UserCenterController(UserService userService) {
        this.userService = userService;
    }

    /**
     * 获取用户信息
     * 请求的时候带上token
     * @return
     */
    @GetMapping("/search")
    public Result<UserInfoDTO> getUserInfo(){
        return userService.getUserInfo();
    }

    /**
     * 修改用户信息
     * @return
     */
    @PostMapping("/update")
    public Result<String> updateUserInfo(@RequestBody UserInfoRequest userInfoRequest){
        return userService.updateUserInfo(userInfoRequest);
    }

    /**
     * 获取用户数量
     * @return
     */
    @GetMapping("/getUserCount")
    public Result<Integer> getUserCount(){
        return userService.getUserCount();
    }
}
